/*
 * @(#)LoginServlet.java	2013-2-3 上午7:09:10
 * order-jsp-servlet
 * Copyright 2013 Thuisoft, Inc. All rights reserved.
 * THUNISOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.thunisoft.order.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.thunisoft.order.domain.TUser;
import com.thunisoft.order.service.IUserService;

/**
 * LoginServlet
 * 
 * @author ice
 * @version 1.0
 * 
 */
public class LoginServlet extends HttpServlet {
    /**
     * 序列版本ID
     */
    private static final long serialVersionUID = -4262950082849917820L;

    @Autowired
    private IUserService userService;
    
//    private IOrderServ

    @Override
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        String sUsername = request.getParameter("username");
        String sPassword = request.getParameter("password");
        TUser user = new TUser(sUsername, sPassword);
        if (userService.login(user)) {
            
            request.getRequestDispatcher("//order-jsp-servlet//welcome.jsp")
                    .forward(request, response);
        }
    }
}
